<template>
	<el-popover placement="bottom" width="300" trigger="click">
		<div style="width: 98%;  padding: 8px;">
			<el-form >
					<div style="height: 20px; line-height: 20px;">
						<h3 align='center'>请输入发货信息</h3>
					</div>
					<div style="height: 10px;"></div>						
					<el-form-item label="发货单号" prop='shipno'>
						<el-input type="text" v-model="form.shipno" placeholder="发货单号" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item label="快递公司或快递员" prop="name">
						<el-input type="text" v-model="form.shipper" placeholder="快递:" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" style="width:100%;" @click="doShip()">确认发货</el-button>
					</el-form-item>
			</el-form>
		</div>	
		<el-button  size="small" effect="plain"  type="warning"  :underline="false"  slot="reference">&nbsp;发货</el-button>	
	</el-popover>
</template>

<script>
	
	import {
		myDate
	} from "@/util"
	
    //import Hello from '@/components/Hello.vue'
	export default {
		props: ["ordid"],
		//components:{Hello},
		data() {
			return {
				form : {shipno:  "", shipper: ""},
			}
		},
		methods:{
			doShip() {
				if (this.form.shipper.length<2 || this.form.shipper.shipno<10) {
					this.$message.error("请输入订单号或快递")
					return;
				}
				this.$emit("shipdone", 1,  this.ordid, this.form.shipno, this.form.shipper);
				this.$postKv("/api/adm/ord/updateShip/" + this.ordid, this.form).then(
				  (resp)=> {
					  if (resp.data.code==200) {
						  this.$message.success(resp.data.msg)
						 this.$emit("shipdone", 1,  this.ordid, this.form.shipno, this.form.shipper);
					  } else {
						  this.$message.error(resp.data.msg)
						  this.$emit("shipdone", 0,  this.ordid, "", "");
					  }
				  }
				)
			}
		},// methods
		mounted() {
			console.log("演示发货窗口是基于 el-popover 组件实现的, 用 this.$emit 发送消息")
			console.log(myDate.formatNow());
			console.log(this.ordid)
			
			let no = "000000" + this.ordid;
			no = no.substring(no.length-6);
			
			this.form.shipno = myDate.formatNow() + no;
		}
	};
</script>

<style>
</style>
